package com.itheima04;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

public class Test04 {
    public static void main(String[] args) {
        ArrayList<File> s1 = new ArrayList<>();
        ArrayList<File> s2 = new ArrayList<>();

        File f = new File("C:\\Users\\阳光正直夏明伟15805655221\\Desktop\\截图\\截图");
        diGui(f, s1, s2);
//        s1.forEach(s -> System.out.println(s));
        Map<String, String> collect = s1.stream().collect(Collectors.toMap(s -> s.getPath(), s -> s.getName()));
        collect.entrySet().forEach(s-> System.out.println(s));


//      s1.stream().collect(Collectors.toMap(s1.))

//        collect.entrySet().forEach(s -> s.getKey());
//        collect.entrySet().forEach(s -> s.getValue());


    }

    public static void diGui(File f, ArrayList<File> s1, ArrayList<File> s2) {
        if (f.isFile()) {
            s1.add(f);
        }
        if (f.isDirectory()) {
            s2.add(f);
            File[] files = f.listFiles();
            if (files != null) {
                for (File file : files) {
                    diGui(file, s1, s2);
                }
            }
        }

    }
}


